package br.com.ponto.model;

import java.util.Calendar;

import javax.persistence.Embeddable;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

import br.com.ponto.enums.Mes;

@Embeddable
public class Competencia {

	@Enumerated(EnumType.STRING)
	private Mes mes;
	private Integer ano;
	
	public Competencia() {
		Calendar data = Calendar.getInstance();
		this.ano = data.get(Calendar.YEAR);
		switch(data.get(Calendar.MONTH)) {
			case Calendar.FEBRUARY : this.mes = Mes.FEV; break;
			case Calendar.MARCH : this.mes = Mes.MAR; break;
			case Calendar.APRIL : this.mes = Mes.ABR; break;
			case Calendar.MAY : this.mes = Mes.MAI; break;
			case Calendar.JUNE : this.mes = Mes.JUN; break;
			case Calendar.JULY : this.mes = Mes.JUL; break;
			case Calendar.AUGUST : this.mes = Mes.AGO; break;
			case Calendar.SEPTEMBER : this.mes = Mes.SET; break;
			case Calendar.OCTOBER : this.mes = Mes.OUT; break;
			case Calendar.NOVEMBER : this.mes = Mes.NOV; break;
			case Calendar.DECEMBER : this.mes = Mes.DEZ; break;
			default : this.mes = Mes.JAN; break;
		}
	}
	
	public Mes getMes() {
		return mes;
	}
	public void setMes(Mes mes) {
		this.mes = mes;
	}
	public Integer getAno() {
		return ano;
	}
	public void setAno(Integer ano) {
		this.ano = ano;
	}
	
	
}
